﻿<?php

//就近 www.jiujin.me
if (!defined('IN_IA')) {
	die('Access Denied');
}
global $_W, $_GPC;
$openid = m('user')->getOpenid();
$set = m('common')->getSysset(array('shop', 'trade'));
if ($_W['isajax']) {
	$member = m('member')->getInfo($openid);
	$member['credit1'] = number_format($member['credit1'], 0);
	$member['credit2'] = number_format($member['credit2'], 2);
	$level = array('levelname' => empty($set['shop']['levelname']) ? '普通会员' : $set['shop']['levelname']);
	if (!empty($member['level'])) {
		$level = m('member')->getLevel($openid);
	}
	$orderparams = array(':uniacid' => $_W['uniacid'], ':openid' => $openid);
	$order = array('status0' => pdo_fetchcolumn('select count(*) from ' . tablename('ewei_shop_order') . ' where TotalId<2 and  openid=:openid and status=0  and uniacid=:uniacid limit 1', $orderparams), 'status1' => pdo_fetchcolumn('select count(*) from ' . tablename('ewei_shop_order') . ' where TotalId<>1 and openid=:openid and status=1 and refundid=0 and uniacid=:uniacid limit 1', $orderparams), 'status2' => pdo_fetchcolumn('select count(*) from ' . tablename('ewei_shop_order') . ' where TotalId<>1 and  openid=:openid and status=2 and refundid=0 and uniacid=:uniacid limit 1', $orderparams), 'status4' => pdo_fetchcolumn('select count(*) from ' . tablename('ewei_shop_order') . ' where TotalId<>1 and openid=:openid and userdeleted=0 and deleted=0 and refundid<>0 and uniacid=:uniacid limit 1', $orderparams));
	if (mb_strlen($member['nickname'], 'utf-8') > 6) {
		$member['nickname'] = mb_substr($member['nickname'], 0, 6, 'utf-8');
	}
	$open_creditshop = false;
	$creditshop = p('creditshop');
	if ($creditshop) {
		$creditshop_set = $creditshop->getSet();
		if (!empty($creditshop_set['centeropen'])) {
			$open_creditshop = true;
		}
	}
	show_json(1, array('member' => $member, 'order' => $order, 'level' => $level, 'open_creditshop' => $open_creditshop));
}
/*
 *  gmm
 *  修改：个人中心增加分销中心
 *  时间：2015年11月19日
 */
$member = m('member')->getMember($openid);
$gift_card=pdo_fetch('select * from '.tablename('mc_members').'where uniacid = :uniacid and uid=:uid',array(':uniacid' => $_W['uniacid'],':uid'=>$member['uid']));
$isagent = $member['isagent'] == 1 && $member['status'] == 1;
//gmm 2015-12-21 大伙伴审核人数小圆点
if($isagent){
	if($member['agentlevel'] == 1 || $member['agentlevel'] == 2){		//战略或大伙伴
		$confirm_num = pdo_fetchcolumn('select count(*) from ' . tablename('ewei_shop_member') . " where uniacid = :uniacid and zhaomu = 1 and status = 0 and isagent = 1 and agentid = :agentid ", 
				array(':uniacid' => $_W['uniacid'], ':agentid' => $member['id']));
	}else{
		$confirm_num = 0;
	}
}
include $this->template('member/center');